#!/usr/bin/env python
# -*- coding: utf-8 -*-
from controls import data_crawl_user_name_mysql
from controls import data_crawl_user_img_mysql

name_file = 'name.json'
result_file = 'result.json'


def flush():
    with open(name_file, 'r') as fp:
        while 1:
            name = fp.readline()

            if not name:
                break

            if not data_crawl_user_name_mysql.add_crawl_user_name_item({
                'name': name
            }):
                print 'error: name=%s' % name

    with open(result_file, 'r') as fp:
        while 1:
            link = fp.readline()

            if not link:
                break

            if not data_crawl_user_img_mysql.add_crawl_user_img_item({
                'imglink': link
            }):
                print 'error: link=%s' % link


if __name__ == '__main__':
    flush()

